const Sequelize = require('sequelize');
const logUtil = require('../untils/logUtil');
const sequelize =new Sequelize('hhqblog', 'root', '564hhq564', {
        host: '47.100.11.130',
        dialect: 'mysql',
       // disable logging; default: console.log
       //logging: false,

       // disable inserting undefined values as NULL
       // - default: false
       omitNull: true,
    define: {
        underscored: false,
        freezeTableName: true,
        charset: 'utf8',
        dialectOptions: {
            collate: 'utf8_general_ci'
        },
    },
    sync: { force: false },
        pool: {
            max: 5, // 连接池中最大连接数量
            min: 0, // 连接池中最小连接数量
            acquire: 30000,
            idle: 10000 // 如果一个线程 10 秒钟内没有被使用过的话，那么就释放线程
        },
    //logging: false

    });
//测试链接
sequelize.authenticate()
    .then(() => {
        console.log('Connection has been established successfully.');

    })
    .catch(err => {
        logUtil.error(err);
        process.exit(process.pid)
    });
module.exports = sequelize;

